home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Scroll / iinterpreterhooks.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.2 KB  |  148 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    iinterpreterhooks.m
  35.  *
  36.  *    Version:    2.0
  37.  *    Author:    Ken Anderson, Ken Fromm
  38.  *    History:
  39.  *            03-07-91        Added this comment.
  40.  */
  41.  
  42. #import "Graphic.h"
  43. #import "ScrollApp.h"
  44. #import <objc/List.h>
  45.  
  46. extern void     initGparms();
  47.  
  48. static UPath    *uPath;
  49. static GParms  gParms;
  50. static id        currentList;
  51.  
  52. void ii_resetPathStruct()
  53. {
  54.     uPath->num_pts = 0;
  55.     uPath->num_ops = 0;
  56. }
  57.  
  58. void ii_initPathStruct()
  59. {
  60.     uPath = [NXApp  getUpathBuffer];
  61.     ii_resetPathStruct();
  62.     currentList = NULL;
  63. }
  64.  
  65. void ii_initGraphicStruct()
  66. {
  67.     initGparms(&gParms);
  68. }
  69.  
  70. void ii_setgray(float  aval)
  71. {
  72.     gParms.color = NXConvertGrayToColor(aval);
  73. }
  74.  
  75. void ii_setlinewidth(float  aval)
  76. {
  77.     gParms.linewidth = aval;
  78. }
  79.  
  80. void ii_setlinejoin(int  aval)
  81. {
  82.     gParms.linejoin = (unsigned char) aval;
  83. }
  84.  
  85. void ii_setdash()
  86. {
  87.     /* setdash not implemented */
  88. }
  89.  
  90. void ii_setmiterlimit(float  aval)
  91. {
  92.     gParms.miterlimit = aval;
  93. }
  94.  
  95. void ii_setlinecap(int  aval)
  96. {
  97.     gParms.linecap = (unsigned char) aval;
  98. }
  99.  
  100. void ii_setrgbcolor(float  r, float g, float b)
  101. {
  102.     gParms.color = NXConvertRGBToColor(r, g, b);
  103. }
  104.  
  105. void ii_insertPathCoord(NXPoint *aPt, int num_pts, char dps_op, NXPoint *currentpoint)
  106. {
  107.     int    i;
  108.  
  109.     for (i = 0;  i < num_pts; i++, aPt++)
  110.     {
  111.         uPath->pts[uPath->num_pts++] = aPt->x;
  112.         uPath->pts[uPath->num_pts++] = aPt->y;
  113.     }
  114.  
  115.     uPath->ops[uPath->num_ops++] = dps_op;        
  116. }
  117.  
  118. void ii_insertPath(int  path_type, NXRect *bounds)
  119. {
  120.     id        aGraphic;
  121.  
  122.     NXRect    bbox;
  123.  
  124.     if (uPath->num_ops > 0)
  125.     {
  126.         bbox = *bounds;
  127.         if (path_type == STROKE)
  128.             NXInsetRect(&bbox, -gParms.linewidth/2, -gParms.linewidth/2);
  129.  
  130.         aGraphic = [Graphic new];
  131.         gParms.path_type = (unsigned char) path_type;
  132.         [aGraphic  installGparms:&gParms];
  133.         [aGraphic  installUpath:uPath  andBounds:&bbox];
  134.  
  135.         if (!currentList)
  136.             currentList = [List new];
  137.  
  138.         [currentList  addObject:aGraphic];
  139.     }
  140. }
  141.  
  142. void ii_insertPage(int  page)
  143. {    
  144.     [[NXApp getDrawingView]  insertList:currentList];
  145.  
  146.     currentList = NULL;
  147. }
  148.